Challenge: Finding the Right Words

In this exercise, you need to figure out how to find the right words in a String according to the given conditions.

We'll cover the following

Problem statement#

Sometimes we can never find the right words to say. At other times, you find too many words, and you have to find the right phrase. That is exactly what we will do in this challenge. We will take a garbled set of sentences and extract what we want from that set.

widget

Coding exercise#

This challenge will test your understanding of String knowledge. The following steps must be done in that order and on the result from the previous step.

1- Remove all the leading and trailing spaces from the given string.

2- Take the result of step 1 and extract all characters between index 0 and 5 inclusive.

3- Take the result of step 2 and convert all letters to uppercase

Only write the code where instructed in the snippet below. You need to store your final result in the variable answer. The return statement and the variable to be returned are already mentioned for you. Don’t worry too much about the return statement for the moment, and just set the value of the answer correctly.

Test your code against our cases, and see if you can pass them.

The solution is given in case​ you get stuck, and the next lesson will include a review of the solution, but it is highly recommended that you try it yourself first!

Good Luck!


In the next lesson, we will see the solution review of this challenge.

String Methods
Solution Review: Finding the Right Words
Mark as Completed
Report an Issue